import Vue from 'vue'
import Router from 'vue-router'
// import Add from '@/components/Add'
// import Collect from '@/components/Collect'
// import Detail from '@/components/Detail'
// import Home from '@/components/Home'
// import List from '@/components/List'

Vue.use(Router)
export default new Router({
  // mode可以指定路由方式,默认是hash(http://localhost:3000/#/home)方式,可以指定history,区别是hash路由会有#号,history(http://127.0.0.1:3000/home)没有#号
  mode: 'history',
  // meta为路由元信息,首次进入home时对首页内容进行缓存
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/add',
      component: () => import('@/components/Add'),
      meta: { title: '添加' }
    },
    {
      path: '/collect',
      component: () => import('@/components/Collect'),
      meta: { title: '收藏' }
    },
    {
      path: '/detail/:bid',
      component: () => import('@/components/Detail'),
      name: 'detail',
      meta: { title: '详情' }
    },
    {
      path: '/home',
      component: () => import('@/components/Home'),
      meta: { keepAlive: true, title: '首页' }
    },
    {
      path: '/list',
      component: () => import('@/components/List'),
      meta: { title: '列表' }
    },
    {
      path: '*',
      redirect: '/home',
      meta: { title: '首页' }
    }
  ]
})
